#!/bin/sh
# Start/stop the GOsa support infrastructure daemon.
#
### BEGIN INIT INFO
# Provides:          gosa-si
# Required-Start:    $syslog $time
# Required-Stop:     $syslog $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: GOsa message server/client component
# Description:       gosa-si establishes the communication between a couple of
#                    GOsa hosting servers and optionally clients to do event
#                    signaling for all communication partners.
### END INIT INFO

# Load defaults
[ -r /etc/default/gosa-si ] && . /etc/default/gosa-si

# Load LSB support functions
. /lib/lsb/init-functions

pidfile="$(sed 2>/dev/null -n 's/^pid-file *= *\([^ ]*\)/\1/p' /etc/gosa-si/client.conf /etc/gosa-si/server.conf | tail -n 1)"
test -z "$pidfile" && pidfile=/var/run/gosa-si-server.pid

case "$1" in
start)  log_daemon_msg "Starting GOsa support infrastructure"
	if [ -x /usr/sbin/gosa-si-server ]; then
		log_progress_msg "daemon"
		start-stop-daemon --start --pidfile "$pidfile" --name gosa-si-server --startas /usr/sbin/gosa-si-server -- $DEBUG
	fi
        log_end_msg $?
	;;
stop)   log_daemon_msg "Stopping GOsa support infrastructure"
	if [ -x /usr/sbin/gosa-si-server ]; then
		log_progress_msg "daemon"
		start-stop-daemon --stop --retry 5 --pidfile "$pidfile" --name gosa-si-server
	fi
        log_end_msg $?
        ;;
reload|force-reload|restart) 
        $0 stop
        $0 start
        ;;
*)	log_action_msg "Usage: /etc/init.d/gosa-si {start|stop|restart|reload|force-reload}"
        exit 2
        ;;
esac
exit 0
